Skip to content

refactor(relay): backend seams prep for local mode (PR 0/12) - #5506

Open
loganj wants to merge 5 commits into
mainfrom
brother-darryl/local-mode-pr0-seams
Open

refactor(relay): backend seams prep for local mode (PR 0/12)#5506
loganj wants to merge 5 commits into
mainfrom
brother-darryl/local-mode-pr0-seams

Conversation

@loganj

@loganj loganj commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

PR 0 of 12 — Backend seams prep (local-mode graduation stack)

First PR of the local-mode graduation train (source branch wip-experiment-local-mode @ b3f365faf, re-cut as a 12-PR stack; plan in the buzz-experiment-local-mode channel canvas).

What this PR does

Mechanical seams-prep refactor with zero hosted-path behavior change:

  • buzz-db-backend-macro crate (new, standalone): compile-time enforcement that every public Db method carries an explicit #[sqlite_backend(...)] decision marker, with trybuild compile-pass/fail coverage. No SQLite implementation code — the macro only enforces future declarations.
  • Relay pubsub/media/presence/config seams: RelayProfile config enum (BUZZ_PROFILE, defaults to production; single-node fails fast at boot — constructor fence, no local backend installed yet), AppState::new_with_backends injection point, redis_pool becomes Option (always Some on the production path), pubsub/media/search backend selection moved behind startup-selected wrappers.
  • Filesystem media backend hardening (pulled forward from the source branch per review): component-aware cross-platform key rejection (traversal, \\, drive/UNC paths), atomic same-directory temp-file writes/copies, seek + bounded take range reads, regression coverage for the traversal/Windows-separator boundary.

Explicitly out of this PR (lands in PR 1 where first exercised): the broad buzz-db/src/lib.rs backend-operation gating, all SQLite persistence, sidecar/desktop work.

Size

24 files, +1,414/−154 = 1,568 changed lines (stack budget: ≤2k after the PR 1 tracer).

Evidence

  • cargo test -p buzz-media — 111 passed / 1 ignored (MinIO, infra-dependent)
  • cargo test -p buzz-db-backend-macro — green (incl. trybuild UI tests)
  • cargo test -p buzz-pubsub — 27 passed / 11 ignored
  • cargo test -p buzz-db --lib — 94 passed / 154 ignored
  • cargo test -p buzz-relay --lib at head vs plain origin/main (2777189d9): identical 858 passed / 9 failed / 40 ignored — the 9 are pre-existing/environmental on the dev host (local Postgres container down: SQLx pool timeouts, admin 404→500, mesh-demo 504) and reproduce byte-for-byte at base. CI's real-database run is the authoritative gate.
  • Full pre-push hook suite green (rust-tests, desktop check/typecheck/test/tauri, mobile-test).

Review

Blocking review by Larry: initial 6/10 (filesystem media boundary needed the source branch's hardening family), fix round closed it, final 10/10 at exactly this head — no remaining blockers or suggestions.

Builder: Brother Darryl. Verification: Wakko (independent test reruns at exact head 8f29ecb).

npub13n66s06epmqf2kc3v373ez8hj65cuzyvxzjf93vwpervxqn2u7jq2qd9je and others added 5 commits August 10, 2026 14:22
Signed-off-by: npub13n66s06epmqf2kc3v373ez8hj65cuzyvxzjf93vwpervxqn2u7jq2qd9je <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz>
Signed-off-by: npub1z3hmzc9ryehxzedl5wzlvpyvja0d483peaja5zt6pd0209f9x2jspe2dxh <146fb160a3266e6165bfa385f6048c975eda9e21cf65da097a0b5ea7952532a5@buzz.block.builderlab.xyz>
Signed-off-by: npub1z3hmzc9ryehxzedl5wzlvpyvja0d483peaja5zt6pd0209f9x2jspe2dxh <146fb160a3266e6165bfa385f6048c975eda9e21cf65da097a0b5ea7952532a5@buzz.block.builderlab.xyz>
Signed-off-by: Brother Darryl <146fb160a3266e6165bfa385f6048c975eda9e21cf65da097a0b5ea7952532a5@buzz.block.builderlab.xyz>
Signed-off-by: Brother Darryl <146fb160a3266e6165bfa385f6048c975eda9e21cf65da097a0b5ea7952532a5@buzz.block.builderlab.xyz>
@loganj
loganj marked this pull request as ready for review August 10, 2026 20:02
@loganj
loganj requested a review from a team as a code owner August 10, 2026 20:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f29ecbdb0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +11 to +12
#[proc_macro_attribute]
pub fn enforce_sqlite_backend_declarations(_args: TokenStream, input: TokenStream) -> TokenStream {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Document the public proc-macro entry point

enforce_sqlite_backend_declarations is a newly exported API but has no function-level documentation explaining its attribute syntax, generated inventory, or compile-time behavior. Add a /// comment to comply with the repository requirement that every new public API be documented.

AGENTS.md reference: AGENTS.md:L117-L117

Useful? React with 👍 / 👎.

Comment on lines +452 to +454
let key = path
.strip_prefix(base)
.unwrap()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Propagate filesystem listing errors instead of panicking

The new non-test filesystem listing path calls unwrap() while processing directory entries, and the same function later introduces an expect() when constructing the continuation token. Replace these with normal error propagation through MediaError; production paths are explicitly prohibited from adding unwrap() or expect(), and a violated path invariant should fail the sweep rather than abort the process.

AGENTS.md reference: AGENTS.md:L116-L116

Useful? React with 👍 / 👎.

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:bot: Jude’s code review agent

Reviewed exact head 8f29ecbdb06ba042b1cc4d833d3d4d74b115fbf7 against stated base bbd20fae75ecc3bd7a83cc12a65379fac22a2b79.

Blocking findings

  1. crates/buzz-media/src/storage.rs:452-455,498-499 adds production unwrap() and expect() calls in the new filesystem listing path. This violates the repository's explicit rule in AGENTS.md:114-117: production paths must not introduce unwrap()/expect() and must use proper errors. The traversal and pagination logic make both invariants plausible, so this is not a claim of a reproduced panic; it is an explicit production-code policy violation. Replace both calls with propagated MediaError/I/O errors, and adjust focused coverage if behavior changes.

  2. crates/buzz-db-backend-macro/src/lib.rs:11-12 exports the new enforce_sqlite_backend_declarations proc-macro entry point without a function-level doc comment. The crate-level overview does not document this public item or its attribute/marker contract. Add /// API documentation as required by AGENTS.md:117.

Author action: Resolve both production panic-policy violations, document the exported proc macro, and resolve/rebase the currently conflicting branch before merge. Any new head requires delta review.

Verification owner: Author for the patch/rebase; reviewer for immutable-head delta inspection plus cargo test -p buzz-media and the macro trybuild suite. CI/integration environment owns Redis-, Postgres-, and MinIO-backed coverage unavailable locally.

Integrated review evidence

The team traced runtime-profile startup fencing, AppBackends injection, in-process pubsub/presence/control and admission limiting, filesystem media traversal/atomic writes/ranges/pagination/sidecars, unsupported search, Git-route suppression, SQLite compile-time selection, and product/UI scope. No client UI delta was found; deliberately rejecting BUZZ_PROFILE=single-node in PR 0/12 is sound scope fencing.

Exact-head local passes reported from clean worktrees:

  • cargo test -p buzz-db-backend-macro — pass, including trybuild
  • cargo test -p buzz-pubsub — 27 passed, 11 Redis-dependent ignored
  • cargo test -p buzz-media — 111 passed, 1 live-MinIO ignored
  • cargo test -p buzz-search — 3 passed, 19 Postgres-dependent ignored

GitHub exact-head checks are green, including Unit Tests, Rust Lint, Backend Integration, Relay E2E, Security, cross-compiles, and DCO. Those are complementary evidence, not exceptions to the repository rules above.

Integration/confidence gaps

GitHub currently reports mergeable: CONFLICTING / mergeStateStatus: DIRTY; conflict resolution will move the immutable review target and needs complete delta/gate review. Local Redis, Postgres search, and live MinIO cases remained ignored due to unavailable services. These are integration/environment gaps rather than additional observed seam regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants